local iputils = require("resty.iputils")
local blocked_ips = {
	"183.27.122.133",
"115.175.140.104",
"120.230.72.86",
"140.250.84.152",
"116.21.94.255",
"183.18.124.171",
"211.97.30.222",
"113.109.215.249",
"119.129.114.131",
"219.136.197.42",
"61.140.199.121",
"113.66.4.118",
"218.20.193.206",
"219.137.110.53",
"113.103.23.207",
"183.18.3.30",
"211.97.30.106",
"219.136.94.99",
"119.129.115.102",
"120.85.97.46",
"113.103.23.208",
"219.72.203.219",
"27.10.185.1",
"113.111.218.66",
"220.112.16.180",
"120.85.158.104",
"183.93.168.87",
"61.140.181.233",
"223.192.6.240",
"59.41.163.163",
"113.66.108.171",
"120.239.73.124",
"223.211.77.30",
"120.85.101.15",
"42.199.54.217",
"219.137.186.204",
"118.196.99.9",
"120.239.148.12",
"120.85.158.29",
"113.67.156.74",
"120.85.158.80",
"219.137.187.122",
"101.47.230.32",
"113.66.5.140",
"59.42.61.115",
"119.33.28.6",
"58.62.39.59",
"59.34.253.106",
"119.131.118.110",
"120.85.99.122",
"219.136.95.4",
"59.41.93.77",
"119.129.129.168",
"120.85.101.94",
"211.97.30.250",
"115.172.110.61",
"113.66.40.172",
"119.129.115.131",
"113.103.90.115",
"14.210.24.139",
"59.42.24.79",
"223.73.116.76",
"58.62.28.225",
"121.68.49.90",
"183.16.191.226",
"113.111.7.168",
"219.136.64.250",
"115.172.105.210",
"42.199.59.107",
"113.119.210.166",
"218.20.193.209",
"58.62.28.1",
"113.111.203.83",
"183.18.45.98",
"120.230.71.153",
"14.145.173.51",
"58.62.50.216",
"183.236.41.137",
"121.32.76.89",
"120.85.76.39",
"101.107.110.57",
"42.199.59.56",
"14.126.109.117",
"119.130.70.12",
"211.97.30.89",
"58.62.31.87",
"120.239.142.13",
"219.136.4.53",
"27.26.192.161",
"223.73.58.167",
"116.21.93.4",
"113.103.23.192",
"116.22.135.199",
"14.145.39.128",
"101.46.39.245",
"211.97.30.156",
"219.136.205.151",
"59.42.63.157",
"116.21.129.54",
"120.26.64.199"
}

local headers = ngx.req.get_headers()
local client_ip = headers["X-FORWARDED-FOR"] or headers["X-REAL-IP"]

blocklist = iputils.parse_cidrs(blocked_ips)
if iputils.ip_in_cidrs(client_ip , blocklist) then
        return ngx.exit(ngx.HTTP_FORBIDDEN)
end
